package priv.stones.date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @Author: Stones
 * @Description:
 * @Date: 2017/9/22 16:13
 */
public class Date1 {

    public static void main(String[] args) {
        Date date = new Date();
        System.out.println(date);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        System.out.println(sdf.format(date));

        Date date1 = null;
        try {
            date1 = sdf.parse("2056-09-22 16:14:");
            System.out.println(date1);
        } catch (ParseException e) {
            System.out.println("parse error");
        }

        Calendar cal = Calendar.getInstance();
        StringBuilder sb = new StringBuilder();
        sb.append(cal.get(Calendar.YEAR)).append("year");
        sb.append(cal.get(Calendar.MONDAY)+1).append("monday");
        sb.append(cal.get(Calendar.DAY_OF_MONTH)).append("day");
        sb.append(cal.get(Calendar.HOUR_OF_DAY)).append("hour");
        sb.append(cal.get(Calendar.MINUTE)).append("minute");
        sb.append(cal.get(Calendar.SECOND)).append("second");
        System.out.println(sb);

    }

}
